home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume9 / elm2 / part02 < prev    next >
Encoding:
Internet Message Format  |  1987-03-08  |  57.8 KB

  1. Subject:  v09i002:  ELM Mail System, Part02/19
  2. Newsgroups: mod.sources
  3. Approved: rs@mirror.TMC.COM
  4.  
  5. Submitted by: Dave Taylor <hplabs!taylor>
  6. Mod.sources: Volume 9, Issue 2
  7. Archive-name: elm2/Part02
  8.  
  9. [  Yes, this is bigger than the News B2.11 distribution... --r$  ]
  10.  
  11. #! /bin/sh
  12. # This is a shell archive.  Remove anything before this line,
  13. # then unpack it by saving it in a file and typing "sh file".
  14. # If this archive is complete, you will see the message:
  15. #        "End of archive 2 (of 19)."
  16. # Contents:  NOTICE doc/elm.1 doc/elmrc-info doc/fastmail.1
  17. #   doc/readmsg.1 filter/utils.c src/Makefile src/Makefile.mstr
  18. #   src/args.c src/bounceback.c src/connect_to.c src/errno.c
  19. #   src/fileio.c src/mkhdrs.c src/showmsg_cmd.c src/softkeys.c
  20. #   utils/printmail.c
  21. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  22. echo shar: Extracting \"NOTICE\" \(2958 characters\)
  23. if test -f NOTICE ; then 
  24.   echo shar: Will not over-write existing file \"NOTICE\"
  25. else
  26. sed "s/^X//" >NOTICE <<'END_OF_NOTICE'
  27. X
  28. X                The Elm(tm) Mail System General Public License
  29. X           
  30. X
  31. X               (C) Copyright 1986, Dave Taylor
  32. X
  33. X
  34. X                  COPYING POLICIES
  35. X
  36. X     Permission is hereby granted for copying and distribution of copies of
  37. X  the Elm source files, and that of any part thereof, subject to the following 
  38. X  license conditions:
  39. X
  40. X        1. You may without additional permission from the author, distribute 
  41. X           Elm or components of Elm, with or without additions developed by 
  42. X           you or by others at no charge.  You may also distribute Elm along 
  43. X           with any other product for sale, provided that the cost of the 
  44. X           bundled package is the same regardless of whether Elm is included,
  45. X           and provided that those interested only in Elm must be notified 
  46. X           that it is product freely available from the author.
  47. X
  48. X        2. Furthermore, if you distribute Elm software or parts of Elm, with 
  49. X           or without additions developed by you or others, then you must 
  50. X           either make available source of all portions of the Elm program 
  51. X           (exclusive of any additions made by you or by others) upon request, 
  52. X           or instead you may notify anyone requesting source that it is 
  53. X           freely available from the author.
  54. X
  55. X        3. In addition, you may not omit any of the copyright notices
  56. X           on either the source files, the executable file, or the 
  57. X           documentation, and
  58. X
  59. X        4. Also, you may not omit transmission of this License agreement with 
  60. X           whatever portions of Elm that are distributed.
  61. X
  62. X        5. Lastly, any users of this software must be notified that it is any 
  63. X           without warrantee, or guarantee of any nature, express or implied, 
  64. X           nor is there any fitness for use represented.
  65. X
  66. XSoftware is a malleable thing - especially Unix - and the author can in no
  67. Xway guarantee that using this program will not cause grevious damage to your
  68. Xsystem.  Of course this isn't anticipated, but if it does happen, the author
  69. Xcannot be held liable for any damages either directly or indirectly caused
  70. Xby this event.
  71. X
  72. XModification of the system is encouraged, providing that the portions of 
  73. Xthe system that are from the original still carry the appropriate copyright
  74. Xnotices and that the changed sections are clearly delimited as such.  The
  75. Xauthor requests copies of any changes made to ensure that the various versions
  76. Xstay reasonably in sync with each other.
  77. X
  78. XNOTE that it is not permitted to copy, sublicense distribute or transfer any
  79. Xof the Elm software except as expressly indicated herein.  Any attempts to
  80. Xdo otherwise will be considered a violation of this license and your rights
  81. Xto the Elm software will be voided.
  82. X
  83. X
  84. XComments on the system and/or this licensing agreement is encouraged.  Send
  85. Xelectronic mail to "taylor@hplabs.HP.COM".  This license was written with
  86. Xhelp from Scott McGregor.  Thanks Scott!
  87. X
  88. X
  89. X----
  90. XElm is a trademark of Dave Taylor. 
  91. END_OF_NOTICE
  92. if test 2958 -ne `wc -c <NOTICE`; then
  93.     echo shar: \"NOTICE\" unpacked with wrong size!?
  94. fi
  95. # end of overwriting check
  96. fi
  97. echo shar: Extracting \"doc/elm.1\" \(2799 characters\)
  98. if test -f doc/elm.1 ; then 
  99.   echo shar: Will not over-write existing file \"doc/elm.1\"
  100. else
  101. sed "s/^X//" >doc/elm.1 <<'END_OF_doc/elm.1'
  102. X.TH ELM 1L 
  103. X.ad b
  104. X.SH NAME
  105. Xelm - an interactive mail system
  106. X.SH SYNOPSIS
  107. X.B elm
  108. X[
  109. X.B \-achkKmrwz
  110. X] [
  111. X.B \-f
  112. X<
  113. X.B file
  114. X>] [
  115. X.B \-d
  116. X<
  117. X.B level
  118. X>]
  119. X.br
  120. X.B elm 
  121. X[
  122. X.B \-s 
  123. X<
  124. X.B subject
  125. X>] <
  126. X.B "list of aliases or addresses"
  127. X>
  128. X.PP
  129. X.SH HP-UX COMPATIBILITY
  130. X.TP 10
  131. XLevel:
  132. XHP-UX/CONTRIBUTED
  133. X.TP
  134. XOrigin:
  135. XHewlett-Packard
  136. X.SH DESCRIPTION
  137. X.I Elm\^
  138. Xis a new interactive mailer program that supercedes 
  139. X.I mail
  140. Xand 
  141. X.I mailx.
  142. X.PP
  143. XThere are three main ways to use the \fBelm\fR mailer; 
  144. Xone way to use the mailer is to specify a list of addresses on the
  145. Xcommand line when the mailer is invoked.  This will allow sending
  146. Xof a single message to the specified recipients with all the
  147. Xoptions usually available in the \fBelm\fR system itself.
  148. X.PP
  149. XThe second way, used most commonly when transmitting files and such,
  150. Xis to specify the subject of the message and the recipients using
  151. Xthe command line and redirect a file as standard input.  For example,
  152. Xthe command 
  153. X.nf
  154. X
  155. X    elm -s testing joe < test.c 
  156. X
  157. X.fi
  158. Xwould mail a copy of the
  159. Xfile test.c to alias joe, with the subject "testing" indicated.
  160. X.PP
  161. XOtherwise, the starting options are;
  162. X.TP 1.0i
  163. X.B "-a"
  164. XArrow - force the arrow cursor (instead of the inverse bar)
  165. X.TP
  166. X.B "-c"
  167. XCheckalias - expand the following aliases and return.
  168. X.TP
  169. X.B "-d <level>"
  170. XDebug - set specified debug level - Output to "$HOME/Elm:debug.info"
  171. X.TP
  172. X.B "-f <file>"
  173. XFile - read file (specified) rather than the incoming mailbox.
  174. X.TP
  175. X.B "-h"
  176. XHelp - give a list of starting options.
  177. X.TP
  178. X.B "?"
  179. XSynonymous with the "-h" option.
  180. X.TP
  181. X.B "-k"
  182. XKeypad - force knowledge of HP terminal keyboard, to allow
  183. Xthe use of the NEXT, PREV and HOME/SHIFT-HOME keys.
  184. X.TP
  185. X.B "-K"
  186. XKeypad + softkeys - enable use of softkeys on HP terminals only.
  187. X.TP
  188. X.B "-m"
  189. XMenu off - Use the extra lines for more message headers.
  190. X.TP
  191. X.B "-s"
  192. XSubject - specify subject for message to mail.
  193. X.TP
  194. X.B "-z"
  195. XZero - don't enter \fBElm\fR if no mail is pending.
  196. X.SH AUTHOR
  197. XDave Taylor, Hewlett-Packard Laboratories
  198. X.SH SEE ALSO
  199. X.I "Elm Users Guide", 
  200. Xby Dave Taylor
  201. X.sp
  202. X.br
  203. X.I "Elm Reference Guide"
  204. Xby Dave Taylor
  205. X.sp 
  206. X.br
  207. X.I "Elm Alias Users Guide"
  208. Xby Dave Taylor
  209. X.sp 
  210. X.br
  211. Xnewalias(1L), checkalias(1L), mail(1), mailx(1), from(1L), printmail(1L)
  212. X.SH FILES
  213. X/usr/local/bin/elm-help.main      help file
  214. X.br
  215. X/usr/mail/.alias_hash             system alias hash table
  216. X.br
  217. X/usr/mail/.alias_data             system alias data table
  218. X.br
  219. X$home/.alias_hash                 user alias hash table
  220. X.br
  221. X$home/.alias_data                 user alias data table
  222. X.br
  223. X/tmp/snd*                         outgoing mail edit buffer
  224. X.br
  225. X/tmp/mbox*                        temporary mailbox
  226. X.br
  227. X$HOME/ELM:debug.info              Debug output if turned on
  228. X.SH DIAGNOSTICS
  229. XShould know about keyboards/softkey terminals other than HP.  (If only 
  230. Xtermcap were that powerful!)
  231. END_OF_doc/elm.1
  232. if test 2799 -ne `wc -c <doc/elm.1`; then
  233.     echo shar: \"doc/elm.1\" unpacked with wrong size!?
  234. fi
  235. # end of overwriting check
  236. fi
  237. echo shar: Extracting \"doc/elmrc-info\" \(2800 characters\)
  238. if test -f doc/elmrc-info ; then 
  239.   echo shar: Will not over-write existing file \"doc/elmrc-info\"
  240. else
  241. sed "s/^X//" >doc/elmrc-info <<'END_OF_doc/elmrc-info'
  242. Xshell
  243. X# The shell to use for shell escapes
  244. X
  245. Xfullname
  246. X# The full user name for outbound mail
  247. X
  248. Xmaildir
  249. X# where to save my mail to, default directory
  250. X
  251. Xmailbox
  252. X# where to save messages to, default file
  253. X
  254. Xeditor
  255. X# what editor to use (none = simulate Berkeley Mail)
  256. X
  257. Xsavemail
  258. X# where to save mail if not specified somewhere else
  259. X
  260. Xcalendar
  261. X# where to save calendar entries
  262. X
  263. Xsortby
  264. X# and how to sort mailboxes, by default
  265. X
  266. Xprint
  267. X# how to print a message ('%s' is the filename)
  268. X
  269. Xprefix
  270. X# prefix sequence for including message text in other messages...
  271. X
  272. Xweedout
  273. X# what headers I DON'T want to see, ever.
  274. X
  275. Xbounceback
  276. X# threshold for bouncing copies of remote uucp messages...
  277. X# zero = disable function.
  278. X
  279. Xtimeout
  280. X# Set the main prompt timeout for resynching...
  281. X
  282. Xautocopy
  283. X# automatically copy message being replied to into buffer? 
  284. X
  285. Xcopy
  286. X# save a copy of all outbound messages? 
  287. X
  288. Xresolve
  289. X# emulate the mailx message increment mode (only increment after something
  290. X# has been 'done' to a message, either saved or deleted, as opposed to 
  291. X# simply each time something is touched)
  292. X
  293. Xweed
  294. X# enable the weedout list to be read...
  295. X
  296. Xnoheader
  297. X# when messages are copied into the outbound buffer, don't include headers
  298. X
  299. Xtitles
  300. X# display message title when displaying pages of message
  301. X
  302. Xeditout
  303. X# edit the headers as the message leaves the machine (sort of)
  304. X
  305. Xsavename
  306. X# save messages, incoming and outbound, by login name of sender/recipient
  307. X
  308. Xmovepage
  309. X# when using the page commands (+ - <NEXT> <PREV>) change the current
  310. X# message pointer...
  311. X
  312. Xpointnew
  313. X# start up by pointing to the first new message received, if possible
  314. X
  315. Xsignature
  316. X# ".signature" files to append to outbound messages...
  317. X
  318. Xlocalsignature
  319. X# local ".signature" files to append to appropriate messages...
  320. X
  321. Xremotesignature
  322. X# remote ".signature" files to append to appropriate messages...
  323. X
  324. Xalwaysleave
  325. X# should we always leave messages as pending (change the default answer to yes)
  326. X
  327. Xalwaysdelete
  328. X# should we always delete messages we've marked for deletion (change the
  329. X# default answer to yes)
  330. X
  331. Xpager
  332. X# program to use for displaying messages ('builtin' is recommended)
  333. X
  334. Xkeypad
  335. X# we're running on an HP terminal and want HOME, PREV, NEXT, etc...
  336. X
  337. Xsoftkeys
  338. X# we're running on an HP terminal and want softkeys available too!
  339. X# (this implies "keypad=ON" too)
  340. X
  341. Xalternatives
  342. X# alternative addresses that I could receive mail from (usually a
  343. X# forwarding mailbox) and don't want to have listed...
  344. X
  345. Xforms
  346. X# we might mail out AT&T Mail Forms
  347. X
  348. Xwarnings
  349. X# tell us about addresses to machines we can't directly get to?
  350. X
  351. Xuserlevel
  352. X# are we good at it?  0=beginner, 1=intermediate, 2+ = expert!
  353. X
  354. Xnames
  355. X# let's just show the names, though, when expanding aliases...
  356. X
  357. Xarrow
  358. X# should we use the "->" rather than the inverse video bar?
  359. X
  360. Xmenu
  361. X# should we display the three-line menus?
  362. END_OF_doc/elmrc-info
  363. if test 2800 -ne `wc -c <doc/elmrc-info`; then
  364.     echo shar: \"doc/elmrc-info\" unpacked with wrong size!?
  365. fi
  366. chmod +x doc/elmrc-info
  367. # end of overwriting check
  368. fi
  369. echo shar: Extracting \"doc/fastmail.1\" \(3033 characters\)
  370. if test -f doc/fastmail.1 ; then 
  371.   echo shar: Will not over-write existing file \"doc/fastmail.1\"
  372. else
  373. sed "s/^X//" >doc/fastmail.1 <<'END_OF_doc/fastmail.1'
  374. X.TH FASTMAIL 1L
  375. X.ad b
  376. X.SH NAME
  377. Xfastmail - quick batch mail interface to a single address
  378. X.SH SYNOPSIS
  379. X.B fastmail
  380. X[-b bcc-list] [-c cc-list] [-d] [-f fromname] [-r replyto] 
  381. X[-s subject] filename address-list
  382. X.br
  383. X.SH HP-UX COMPATIBILITY
  384. X.TP 10
  385. XLevel:
  386. XHP-UX/CONTRIBUTED
  387. X.TP
  388. XOrigin:
  389. XHewlett-Packard
  390. X.SH DESCRIPTION
  391. X.I Fastmail
  392. Xis a low-level interface to the mail system that allows batch
  393. Xprocessing of mail.  It's intended for mailing to very large
  394. Xgroups of people in a staggered fashion. 
  395. X.PP
  396. XThe starting options are;
  397. X.TP 1.0i
  398. X.B "-b bcc-list"
  399. XThis allows a list of people to receive blind-carbon copies, or BCCs, of
  400. Xthe message.  This list should be full email addresses.
  401. X.TP
  402. X.B "-c cc-list"
  403. XThis allows a list of people to receive carbon copies, or CCs, of
  404. Xthe message.  This list should be full email addresses.
  405. X.TP
  406. X.B "-d"
  407. XDebug.  This is helpful for strange, unfriendly errors from
  408. Xthe program (etc).
  409. X.TP
  410. X.B "-f from"
  411. XThis overrides the users name in the From: line, so that if
  412. Xthe user was x@y, and their name was MrX then the default 
  413. XFrom: line would be "From: x@y (MrX)".  Using "-f Joe" when
  414. Xinvoking this, though, would change it to "From: x@y (Joe)"
  415. X.TP
  416. X.B "-r replyto"
  417. XOccasionally, you might send mail but want the replies to go
  418. Xto a different address (very common with mailing lists).  
  419. XThere is a header for this purpose called "Reply-To:" which
  420. Xcan be utilized by using this starting option.  For example,
  421. Xwe could send mail with a reply-to to list-request by
  422. Xusing "-r list-request".  The header generated would then
  423. Xbe of the form "Reply-To: list-request".
  424. X.TP
  425. X.B "-s subject"
  426. XThe subject of the message is specified by using 
  427. Xthis starting option.
  428. X.SH EXAMPLE
  429. XLet's say we're user "big" on machine "big-vax" and we have a
  430. Xshell script called 'batch-mail' that contains the following
  431. Xlines:
  432. X.nf
  433. X
  434. X   #
  435. X   # Batch Mail - batch mailing of a file to a LOT of users
  436. X   #  
  437. X   # Usage: batch-mail "from" "subject" filename
  438. X
  439. X   sender_copy = $LOGIN
  440. X   replto = "The-Mr-Big-list"
  441. X
  442. X   fastmail -b $sender_copy -r $replyto -f "$1" -s "$2" $3 person1
  443. X   sleep 10
  444. X   fastmail -r $replyto -f "$1" -s "$2" $3 person2
  445. X   sleep 10
  446. X   fastmail -r $replyto -f "$1" -s "$2" $3 person3
  447. X   sleep 10
  448. X   fastmail -r $replyto -f "$1" -s "$2" $3 person4
  449. X
  450. X   < etc >
  451. X
  452. Xwith the invocation:
  453. X
  454. X   batch-mail "Mr. Big" "Warning to all" warning.text
  455. X
  456. X.fi
  457. Xwould mail a copy of the 'warning.text' file to person1, person2, 
  458. Xperson3, etc.  "$LOGIN" will also receive a copy of the first message
  459. Xin the mail, \fIsilently\fR.  Each resultant message will include the headers:
  460. X.nf
  461. X
  462. X    From: big-vax!big (Mr. Big)
  463. X    Subject: Warning to all
  464. X    Reply-To: The-Mr-Big-list
  465. X
  466. X.fi
  467. XThis program should turn out to be considerably
  468. Xfaster than the alternative methods of accomplishing this task.
  469. X.SH FILES
  470. X/usr/lib/sendmail       sendmail transport if available
  471. X.br
  472. X/bin/rmail              transport if no sendmail
  473. X.br
  474. X/tmp/fastmail.$$        temporary file 
  475. X.SH AUTHOR
  476. XDave Taylor, Hewlett-Packard Laboratories
  477. X.SH SEE\ ALSO
  478. Xsendmail(1), rmail(1), elm(1L)
  479. END_OF_doc/fastmail.1
  480. if test 3033 -ne `wc -c <doc/fastmail.1`; then
  481.     echo shar: \"doc/fastmail.1\" unpacked with wrong size!?
  482. fi
  483. # end of overwriting check
  484. fi
  485. echo shar: Extracting \"doc/readmsg.1\" \(3666 characters\)
  486. if test -f doc/readmsg.1 ; then 
  487.   echo shar: Will not over-write existing file \"doc/readmsg.1\"
  488. else
  489. sed "s/^X//" >doc/readmsg.1 <<'END_OF_doc/readmsg.1'
  490. X.TH READMSG 1L
  491. X.ad b
  492. X.SH NAME
  493. Xreadmsg - read messages from incoming mail
  494. X.SH SYNOPSIS
  495. X.B readmsg 
  496. X[\fB-p\fR]
  497. X[\fB-n\fR]
  498. X[\fB-f filename\fR]
  499. X[\fB-h\fR]
  500. X.br
  501. X.B readmsg
  502. X[\fB-p\fR]
  503. X[\fB-n\fR]
  504. X[\fB-f filename\fR]
  505. X[\fB-h\fR]
  506. Xnumber [number ...]
  507. X.br
  508. X.B readmsg 
  509. X[\fB-p\fR]
  510. X[\fB-n\fR]
  511. X[\fB-f filename\fR]
  512. X[\fB-h\fR]
  513. Xpattern
  514. X.br
  515. X.SH HP-UX COMPATIBILITY
  516. X.TP 10
  517. XLevel:
  518. XHP-UX/CONTRIBUTED
  519. X.TP
  520. XOrigin:
  521. XHewlett-Packard
  522. X.SH DESCRIPTION
  523. X.I Readmsg
  524. Xis a program that gives the \fBElm\fR user the functionality of
  525. Xthe mailx "~r" command from the editor of their choice.  There
  526. Xare three different ways of using the program;
  527. X.P
  528. XFirst off, if you're actually creating a reply to a message
  529. Xfrom within the \fBElm\fR system then \fIreadmsg\fR without any
  530. Xarguments will include a summary of the headers and the body 
  531. Xof the message being replied
  532. Xto.  If you aren't currently editing a message the program will
  533. Xreturn an error.
  534. X.P
  535. XSecondly, if you want to include certain messages, you can
  536. Xspecify them by listing their ordinal locations in the 
  537. Xmail file (that is, their "message numbers")
  538. Xup to 25 at a time.  The \fImeta-\fRnumber '$' is understood to mean
  539. Xthe last message in the mailfile.  Similarly, '*' is understood to
  540. Xrepresent every message in the file (that is, 1-$)
  541. X.P
  542. XFinally, you can also specify a pattern that occurs in one of
  543. Xthe messages as a way of including it.  This pattern can be
  544. Xtyped in directly (no quotes) if the words are separated by a 
  545. Xsingle space in the actual message.  The pattern matching is case
  546. Xsensitive, so "Hello" and "hello" are NOT the same thing!!
  547. X.sp
  548. X.P
  549. XThe \fB-f\fR flag indicates that you'd rather use the file specified
  550. Xfor the operations specified rather than the default mailbox (see
  551. Xthe way \fBElm\fR implements printing multiple messages for more
  552. Xinformation on this...)
  553. X.P
  554. XThe \fB-h\fR flag instructs the program to include the entire header
  555. Xof the matched message or messages when displaying their
  556. Xtext.  (default is to display the From: Date: and Subject: lines
  557. Xonly)
  558. X.P
  559. XThe \fB-n\fR flag instructs the program to exclude \fIall\fR
  560. Xheaders.  This is used mostly for extracting files mailed and
  561. Xsuch.
  562. X.P
  563. XFinally, the \fB-p\fR flag indicates that the program should
  564. Xput form-feeds (control-L) between message headers.
  565. X.sp
  566. X.SH "EXAMPLES"
  567. XFirst off, to use this from within \fBvi\fR to include the text of the 
  568. Xcurrent message at the end of the current message, you could
  569. Xuse the command;
  570. X.nf
  571. X
  572. X    !!readmsg
  573. X
  574. X.fi
  575. X(as you hit the 'G' the editor will put you at the bottom of the screen
  576. Xwith the '!' prompt).
  577. X.sp 2
  578. XLet's look at something more interesting, however;
  579. X.sp
  580. XSuppose you have the mailfile;
  581. X.nf
  582. X
  583. X   From joe Jun 3 1986 4:45:30 MST
  584. X   Subject: hello
  585. X   
  586. X   Hey Guy!  Wanta go out and have a milk this evening?
  587. X   
  588. X   Joe
  589. X   
  590. X   From john Jun 3 1986 4:48:20 MST
  591. X   Subject: Dinner at Eight
  592. X   From: John Dinley <xyz!john>
  593. X
  594. X   Remember you should show up about eight, okay?
  595. X
  596. X           - John D -
  597. X
  598. X   From xxzyz!cron Jun 3 1986 5:02:43 MST
  599. X
  600. X   Cannot connect to server: blob
  601. X   Job 43243 deleted from queue.
  602. X   
  603. X.fi
  604. XThe following commands will result in;
  605. X.nf
  606. X
  607. X  $ readmsg 2        
  608. X  [ display the second message, from John ]
  609. X
  610. X  $ readmsg         
  611. X  [ an error, unless we're calling from \fBElm\fR ]
  612. X
  613. X  $ readmsg BLOB    
  614. X  [ no match - case sensitive! ]
  615. X
  616. X  $ readmsg -h connect to server 
  617. X  [ displays third message, including headers ]
  618. X
  619. X.fi
  620. X.SH FILES
  621. X/usr/mail/<username>           The incoming mail
  622. X.br
  623. X$home/.readmsg            The temp file from \fBElm\fR
  624. X.SH AUTHOR
  625. XDave Taylor, Hewlett-Packard Laboratories
  626. X.SH SEE\ ALSO
  627. Xnewmail(1L), Elm(1L)
  628. X.SH BUGS
  629. XThe '*' metacharacter doesn't always work as expected!
  630. X.br
  631. XPerhaps the pattern matching should be case insensitive?
  632. END_OF_doc/readmsg.1
  633. if test 3666 -ne `wc -c <doc/readmsg.1`; then
  634.     echo shar: \"doc/readmsg.1\" unpacked with wrong size!?
  635. fi
  636. # end of overwriting check
  637. fi
  638. echo shar: Extracting \"filter/utils.c\" \(2862 characters\)
  639. if test -f filter/utils.c ; then 
  640.   echo shar: Will not over-write existing file \"filter/utils.c\"
  641. else
  642. sed "s/^X//" >filter/utils.c <<'END_OF_filter/utils.c'
  643. X/**            utils.c                **/
  644. X
  645. X/** Utility routines for the filter program...
  646. X
  647. X   (C) Copyright 1986, Dave Taylor
  648. X**/
  649. X
  650. X#include <stdio.h>
  651. X#include <pwd.h>
  652. X#include <ctype.h>
  653. X#include <fcntl.h>
  654. X
  655. X#include "defs.h"
  656. X#include "filter.h"
  657. X
  658. Xleave(reason)
  659. Xchar *reason;
  660. X{
  661. X    fprintf(stderr,"%sfilter (%s): LEAVE %s\n", BEEP, username, reason);
  662. X    exit(1);
  663. X}
  664. X
  665. Xlog(what)
  666. Xint what;
  667. X{
  668. X    /** make an entry in the log files for the specified entry **/
  669. X
  670. X    FILE *fd;
  671. X    char filename[SLEN];
  672. X
  673. X    if (! show_only) {
  674. X      sprintf(filename, "%s/%s", home, filtersum);    /* log action once! */
  675. X      if ((fd = fopen(filename, "a")) == NULL) {
  676. X        fprintf(stderr,"%sfilter (%s): Couldn't open log file %s\n", 
  677. X            BEEP, filename);
  678. X        fd = stdout;
  679. X      }
  680. X      fprintf(fd, "%d\n", rule_choosen);
  681. X      fclose(fd);
  682. X    }
  683. X
  684. X    sprintf(filename, "%s/%s", home, filterlog);
  685. X
  686. X    if (show_only)
  687. X      fd = stdout;
  688. X    else if ((fd = fopen(filename, "a")) == NULL) {
  689. X      fprintf(stderr,"%sfilter (%s): Couldn't open log file %s\n", 
  690. X          BEEP, filename);
  691. X      fd = stdout;
  692. X    }
  693. X    
  694. X    setvbuf(fd, NULL, _IOFBF, BUFSIZ);
  695. X
  696. X    if (strlen(from) + strlen(subject) > 60)
  697. X      fprintf(fd, "\nMail from %s\n\tabout %s\n", from, subject);
  698. X    else
  699. X      fprintf(fd, "\nMail from %s about %s\n", from, subject);
  700. X
  701. X    if (rule_choosen != -1)
  702. X      if (rules[rule_choosen].condition->matchwhat == TO)
  703. X        fprintf(fd, "\t(addressed to %s)\n", to);
  704. X
  705. X    switch (what) {
  706. X      case DELETE : fprintf(fd, "\tDELETED");            break;
  707. X      case SAVE   : fprintf(fd, "\tSAVED in file \"%s\"", 
  708. X                rules[rule_choosen].argument2);        break;
  709. X      case SAVECC : fprintf(fd,"\tSAVED in file \"%s\" AND PUT in mailbox", 
  710. X                rules[rule_choosen].argument2);      break;
  711. X      case FORWARD: fprintf(fd, "\tFORWARDED to \"%s\"", 
  712. X                rules[rule_choosen].argument2);        break;
  713. X      case EXEC   : fprintf(fd, "\tEXECUTED \"%s\"",
  714. X                rules[rule_choosen].argument2);        break;
  715. X      case LEAVE  : fprintf(fd, "\tPUT in mailbox");        break;
  716. X    }
  717. X
  718. X    if (rule_choosen != -1)
  719. X      fprintf(fd, " by rule #%d\n", rule_choosen+1);
  720. X    else
  721. X      fprintf(fd, ": the default action\n");
  722. X
  723. X    fflush(fd);
  724. X    fclose(fd);
  725. X}
  726. X
  727. Xint
  728. Xcontains(string, pattern)
  729. Xchar *string, *pattern;
  730. X{
  731. X    /** Returns TRUE iff pattern occurs IN IT'S ENTIRETY in buffer. **/ 
  732. X
  733. X    register int i = 0, j = 0;
  734. X
  735. X    while (string[i] != '\0') {
  736. X      while (tolower(string[i++]) == tolower(pattern[j++])) 
  737. X        if (pattern[j] == '\0') 
  738. X          return(TRUE);
  739. X      i = i - j + 1;
  740. X      j = 0;
  741. X    }
  742. X    return(FALSE);
  743. X}
  744. X
  745. Xchar *itoa(i, two_digit)
  746. Xint i, two_digit;
  747. X{    
  748. X    /** return 'i' as a null-terminated string.  If two-digit use that
  749. X        size field explicitly!  **/
  750. X
  751. X    static char value[10];
  752. X    
  753. X    if (two_digit)
  754. X      sprintf(value, "%02d", i);
  755. X    else
  756. X      sprintf(value, "%d", i);
  757. X
  758. X    return( (char *) value);
  759. X}
  760. X
  761. Xlowercase(string)
  762. Xchar *string;
  763. X{
  764. X    /** translate string into all lower case **/
  765. X
  766. X    register int i;
  767. X
  768. X    for (i=0; i < strlen(string); i++)
  769. X      if (isupper(string[i]))
  770. X        string[i] = tolower(string[i]);
  771. X}
  772. END_OF_filter/utils.c
  773. if test 2862 -ne `wc -c <filter/utils.c`; then
  774.     echo shar: \"filter/utils.c\" unpacked with wrong size!?
  775. fi
  776. # end of overwriting check
  777. fi
  778. echo shar: Extracting \"src/Makefile\" \(2597 characters\)
  779. if test -f src/Makefile ; then 
  780.   echo shar: Will not over-write existing file \"src/Makefile\"
  781. else
  782. sed "s/^X//" >src/Makefile <<'END_OF_src/Makefile'
  783. X#
  784. X#  Makefile for the ELM mail program.
  785. X#
  786. X#         (C) Copyright 1986, Dave Taylor
  787. X#
  788. X#  Last modification: August 15th, 1986
  789. X
  790. XSHELL=/bin/sh
  791. X
  792. XDEFINE= -DBSD
  793. XLIB2  = -lcurses
  794. X
  795. X# IF you're on an ACSnet system (Australia) then
  796. X# you'll want to uncomment the following;
  797. X
  798. X#   DEFINE= ${DEFINE} -DACSNET
  799. X
  800. X##############################
  801. X
  802. XCFILES=    addr_utils.c alias.c aliasdb.c aliaslib.c args.c bounceback.c     \
  803. X    builtin.c calendar.c connect_to.c curses.c date.c delete.c    \
  804. X    domains.c edit.c editmsg.c elm.c encode.c errno.c file.c    \
  805. X    file_utils.c fileio.c forms.c getopt.c hdrconfg.c help.c    \
  806. X    initialize.c input_utils.c leavembox.c limit.c mailmsg1.c    \
  807. X    mailmsg2.c mailtime.c mkhdrs.c newmbox.c opt_utils.c options.c    \
  808. X    output_utils.c pattern.c pmalloc.c quit.c read_rc.c remail.c    \
  809. X    reply.c return_addr.c savecopy.c screen.c showmsg.c signals.c    \
  810. X    softkeys.c sort.c string2.c strings.c syscall.c utils.c        \
  811. X    save_opts.c validname.c
  812. X
  813. XHEADERS=../hdrs/curses.h ../hdrs/defs.h ../hdrs/headers.h ../hdrs/sysdefs.h
  814. X
  815. XOBJS  =    addr_utils.o alias.o aliasdb.o aliaslib.o args.o bounceback.o     \
  816. X    builtin.o calendar.o connect_to.o curses.o date.o delete.o    \
  817. X    domains.o edit.o editmsg.o elm.o encode.o errno.o file.o    \
  818. X    file_utils.o fileio.o forms.o getopt.o hdrconfg.o help.o    \
  819. X    initialize.o input_utils.o leavembox.o limit.o mailmsg1.o    \
  820. X    mailmsg2.o mailtime.o mkhdrs.o newmbox.o opt_utils.o options.o    \
  821. X    output_utils.o pattern.o pmalloc.o quit.o read_rc.o remail.o    \
  822. X    reply.o return_addr.o savecopy.o screen.o showmsg.o signals.o    \
  823. X    softkeys.o sort.o string2.o strings.o syscall.o utils.o        \
  824. X    save_opts.o validname.o
  825. X
  826. XBIN=    ../bin
  827. XLIBS=   -ltermcap
  828. XCFLAGS= -O -I../hdrs
  829. XCC=    /bin/cc
  830. XRM=    /bin/rm -f
  831. X
  832. X../bin/elm: ${OBJS} ${EXTRA} ${HEADERS} ../hdrs/elm.h
  833. X    ${CC} -o ${BIN}/elm -n ${OBJS} ${LIBS} ${LIB2}
  834. X
  835. X.c.o:   ${HEADERS}
  836. X    ${CC} -c ${CFLAGS} ${DEFINE} $*.c 
  837. X
  838. Xcurses.o: curses.c ../hdrs/curses.h
  839. X    ${CC} -c ${CFLAGS} -DRAWMODE ${DEFINE} curses.c
  840. X
  841. X# curses.c : curses.q
  842. X#     @../bin/quickscreen curses.q
  843. X#
  844. X# curses.q :
  845. X#     @cp curses.c curses.q
  846. X
  847. Xclean:
  848. X    ${RM} ${OBJS} LINT.OUT ../bin/elm 
  849. X
  850. Xlint: LINT.OUT
  851. X
  852. XLINT.OUT: ${CFILES}
  853. X    lint -DRAWMODE -I../hdrs ${CFILES} -ltermcap > LINT.OUT
  854. X
  855. Xlisting: LISTING
  856. X
  857. XLISTING: Makefile INDEX ${HEADERS} ${CFILES}
  858. X    @echo adding file 'Makefile'...
  859. X    @/bin/echo \\f > LISTING
  860. X    @cat Makefile >> LISTING
  861. X    @echo adding file 'INDEX'...
  862. X    @/bin/echo \\f >> LISTING
  863. X    @cat INDEX >> LISTING
  864. X    @../bin/makelisting ${HEADERS} ${CFILES}
  865. X    @echo LISTING generated.
  866. X
  867. Xindex: INDEX
  868. X
  869. XINDEX: ${CFILES} ${HEADERS}
  870. X    @echo Creating function definition index
  871. X    @index *.c | sort > INDEX
  872. X    @echo File INDEX generated
  873. END_OF_src/Makefile
  874. if test 2597 -ne `wc -c <src/Makefile`; then
  875.     echo shar: \"src/Makefile\" unpacked with wrong size!?
  876. fi
  877. # end of overwriting check
  878. fi
  879. echo shar: Extracting \"src/Makefile.mstr\" \(2589 characters\)
  880. if test -f src/Makefile.mstr ; then 
  881.   echo shar: Will not over-write existing file \"src/Makefile.mstr\"
  882. else
  883. sed "s/^X//" >src/Makefile.mstr <<'END_OF_src/Makefile.mstr'
  884. X#
  885. X#  Makefile for the ELM mail program.
  886. X#
  887. X#         (C) Copyright 1986, Dave Taylor
  888. X#
  889. X#  Last modification: August 15th, 1986
  890. X
  891. XSHELL=/bin/sh
  892. X
  893. XDEFINE= >os-define<
  894. XLIB2  = >lib2<
  895. X
  896. X# IF you're on an ACSnet system (Australia) then
  897. X# you'll want to uncomment the following;
  898. X
  899. X#   DEFINE= ${DEFINE} -DACSNET
  900. X
  901. X##############################
  902. X
  903. XCFILES=    addr_utils.c alias.c aliasdb.c aliaslib.c args.c bounceback.c     \
  904. X    builtin.c calendar.c connect_to.c curses.c date.c delete.c    \
  905. X    domains.c edit.c editmsg.c elm.c encode.c errno.c file.c    \
  906. X    file_utils.c fileio.c forms.c getopt.c hdrconfg.c help.c    \
  907. X    initialize.c input_utils.c leavembox.c limit.c mailmsg1.c    \
  908. X    mailmsg2.c mailtime.c mkhdrs.c newmbox.c opt_utils.c options.c    \
  909. X    output_utils.c pattern.c pmalloc.c quit.c read_rc.c remail.c    \
  910. X    reply.c return_addr.c savecopy.c screen.c showmsg.c signals.c    \
  911. X    softkeys.c sort.c string2.c strings.c syscall.c utils.c        \
  912. X    save_opts.c validname.c
  913. X
  914. XHEADERS=../hdrs/curses.h ../hdrs/defs.h ../hdrs/headers.h ../hdrs/sysdefs.h
  915. X
  916. XOBJS  =    addr_utils.o alias.o aliasdb.o aliaslib.o args.o bounceback.o     \
  917. X    builtin.o calendar.o connect_to.o curses.o date.o delete.o    \
  918. X    domains.o edit.o editmsg.o elm.o encode.o errno.o file.o    \
  919. X    file_utils.o fileio.o forms.o getopt.o hdrconfg.o help.o    \
  920. X    initialize.o input_utils.o leavembox.o limit.o mailmsg1.o    \
  921. X    mailmsg2.o mailtime.o mkhdrs.o newmbox.o opt_utils.o options.o    \
  922. X    output_utils.o pattern.o pmalloc.o quit.o read_rc.o remail.o    \
  923. X    reply.o return_addr.o savecopy.o screen.o showmsg.o signals.o    \
  924. X    softkeys.o sort.o string2.o strings.o syscall.o utils.o        \
  925. X    save_opts.o validname.o
  926. X
  927. XBIN=    ../bin
  928. XLIBS=   >libs<
  929. XCFLAGS= -O -I../hdrs
  930. XCC=    >cc<
  931. XRM=    >rm<
  932. X
  933. X../bin/elm: ${OBJS} ${EXTRA} ${HEADERS} ../hdrs/elm.h
  934. X    ${CC} -o ${BIN}/elm -n ${OBJS} ${LIBS} ${LIB2}
  935. X
  936. X.c.o:   ${HEADERS}
  937. X    ${CC} -c ${CFLAGS} ${DEFINE} $*.c 
  938. X
  939. Xcurses.o: curses.c ../hdrs/curses.h
  940. X    ${CC} -c ${CFLAGS} -DRAWMODE ${DEFINE} curses.c
  941. X
  942. X# curses.c : curses.q
  943. X#     @../bin/quickscreen curses.q
  944. X#
  945. X# curses.q :
  946. X#     @cp curses.c curses.q
  947. X
  948. Xclean:
  949. X    ${RM} ${OBJS} LINT.OUT ../bin/elm 
  950. X
  951. Xlint: LINT.OUT
  952. X
  953. XLINT.OUT: ${CFILES}
  954. X    lint -DRAWMODE -I../hdrs ${CFILES} -ltermcap > LINT.OUT
  955. X
  956. Xlisting: LISTING
  957. X
  958. XLISTING: Makefile INDEX ${HEADERS} ${CFILES}
  959. X    @echo adding file 'Makefile'...
  960. X    @/bin/echo \\f > LISTING
  961. X    @cat Makefile >> LISTING
  962. X    @echo adding file 'INDEX'...
  963. X    @/bin/echo \\f >> LISTING
  964. X    @cat INDEX >> LISTING
  965. X    @../bin/makelisting ${HEADERS} ${CFILES}
  966. X    @echo LISTING generated.
  967. X
  968. Xindex: INDEX
  969. X
  970. XINDEX: ${CFILES} ${HEADERS}
  971. X    @echo Creating function definition index
  972. X    @index *.c | sort > INDEX
  973. X    @echo File INDEX generated
  974. END_OF_src/Makefile.mstr
  975. if test 2589 -ne `wc -c <src/Makefile.mstr`; then
  976.     echo shar: \"src/Makefile.mstr\" unpacked with wrong size!?
  977. fi
  978. # end of overwriting check
  979. fi
  980. echo shar: Extracting \"src/args.c\" \(2975 characters\)
  981. if test -f src/args.c ; then 
  982.   echo shar: Will not over-write existing file \"src/args.c\"
  983. else
  984. sed "s/^X//" >src/args.c <<'END_OF_src/args.c'
  985. X/**            args.c            **/
  986. X
  987. X/** starting argument parsing routines for ELM system...
  988. X
  989. X    (C) Copyright 1986 Dave Taylor
  990. X**/
  991. X
  992. X#include "headers.h"
  993. X
  994. X#define DONE        0
  995. X#define ERROR        -1
  996. X
  997. Xextern char *optional_arg;        /* optional argument as we go */
  998. Xextern int   opt_index;            /* argnum + 1 when we leave   */
  999. X
  1000. Xvoid exit();    /* just keeping lint happy.... */
  1001. X
  1002. Xparse_arguments(argc, argv, to_whom)
  1003. Xint argc;
  1004. Xchar *argv[], *to_whom;
  1005. X{
  1006. X    /** Set flags according to what was given to program.  If we are 
  1007. X        fed a name or series of names, put them into the 'to_whom' buffer
  1008. X        and set "mail_only" to TRUE **/
  1009. X
  1010. X    register int c = 0, check_size = 0;
  1011. X    char *strcpy();
  1012. X
  1013. X    infile[0] = '\0';
  1014. X    to_whom[0] = '\0';
  1015. X    batch_subject[0] = '\0';
  1016. X
  1017. X    while ((c = get_options(argc, argv, "?acd:f:hkKms:wz")) > 0) {
  1018. X       switch (c) {
  1019. X         case 'a' : arrow_cursor++;        break;
  1020. X         case 'c' : check_only++;        break;
  1021. X         case 'd' : debug = atoi(optional_arg);    break;
  1022. X         case 'f' : strcpy(infile, optional_arg); 
  1023. X                    mbox_specified = 2;  break;
  1024. X         case '?' :
  1025. X         case 'h' : args_help();
  1026. X         case 'k' : hp_terminal++;    break;
  1027. X         case 'K' : hp_terminal++; hp_softkeys++;    break;
  1028. X         case 'm' : mini_menu = 0;    break;
  1029. X         case 's' : strcpy(batch_subject, optional_arg);    break;
  1030. X         case 'w' : warnings = 0;    break;
  1031. X         case 'z' : check_size++;   break;
  1032. X        }
  1033. X     }
  1034. X
  1035. X     if (c == ERROR) {
  1036. X       printf(
  1037. X          "Usage: %s [achkKmwz] [-d level] [-f file] [-s subject] <names>\n\n",
  1038. X         argv[0]);
  1039. X       args_help();
  1040. X    }
  1041. X
  1042. X    if (opt_index < argc) {
  1043. X      while (opt_index < argc) {
  1044. X        sprintf(to_whom, "%s%s%s", to_whom, 
  1045. X                to_whom[0] != '\0'? " " : "", argv[opt_index]);
  1046. X        mail_only++;
  1047. X        opt_index++;
  1048. X      }
  1049. X      check_size = 0;    /* NEVER do this if we're mailing!! */
  1050. X    }
  1051. X
  1052. X     if (strlen(batch_subject) > 0 && ! mail_only) 
  1053. X       exit(printf(
  1054. X     "\n\rDon't understand specifying a subject and no-one to send to!\n\r"));
  1055. X
  1056. X    if (!isatty(fileno(stdin)) && strlen(batch_subject) == 0 && !check_only)
  1057. X      strcpy(batch_subject, DEFAULT_BATCH_SUBJECT);
  1058. X
  1059. X    if (check_size)
  1060. X      check_mailfile_size();
  1061. X}
  1062. X
  1063. Xargs_help()
  1064. X{
  1065. X    /**  print out possible starting arguments... **/
  1066. X
  1067. X    printf("\nPossible Starting Arguments for ELM program:\n\n");
  1068. X    printf("\targ\t\t\tMeaning\n");
  1069. X    printf("\t -a \t\tArrow - use the arrow pointer regardless\n");
  1070. X    printf("\t -c \t\tCheckalias - check the given aliases only\n");
  1071. X    printf("\t -dn\t\tDebug - set debug level to 'n'\n");
  1072. X    printf("\t -fx\t\tFile - read file 'x' rather than mailbox\n");
  1073. X    printf("\t -h \t\tHelp - give this list of options\n");
  1074. X    printf("\t -k \t\tKeypad - enable HP 2622 terminal keyboard\n");
  1075. X    printf("\t -K \t\tKeypad&softkeys - enable use of softkeys + \"-k\"\n");
  1076. X    printf("\t -m \t\tMenu - Turn off menu, using more of the screen\n");
  1077. X    printf("\t -sx\t\tSubject 'x' - for batchmailing\n");
  1078. X    printf("\t -w \t\tSupress warning messages...\n");
  1079. X    printf("\t -z \t\tZero - don't enter Elm if no mail is pending\n");
  1080. X    printf("\n");
  1081. X    printf("\n");
  1082. X    exit(1);
  1083. X}
  1084. END_OF_src/args.c
  1085. if test 2975 -ne `wc -c <src/args.c`; then
  1086.     echo shar: \"src/args.c\" unpacked with wrong size!?
  1087. fi
  1088. # end of overwriting check
  1089. fi
  1090. echo shar: Extracting \"src/bounceback.c\" \(2525 characters\)
  1091. if test -f src/bounceback.c ; then 
  1092.   echo shar: Will not over-write existing file \"src/bounceback.c\"
  1093. else
  1094. sed "s/^X//" >src/bounceback.c <<'END_OF_src/bounceback.c'
  1095. X/**            bounceback.c            **/
  1096. X
  1097. X/** This set of routines implement the bounceback feature of the mailer.
  1098. X    This feature allows mail greater than 'n' hops away (n specified by
  1099. X    the user) to have a 'cc' to the user through the remote machine.  
  1100. X
  1101. X    Due to the vagaries of the Internet addressing (uucp -> internet -> uucp)
  1102. X    this will NOT generate bounceback copies with mail to an internet host!
  1103. X
  1104. X    (C) Copyright 1986 by Dave Taylor
  1105. X**/
  1106. X
  1107. X#include "headers.h"
  1108. X
  1109. Xchar *bounce_off_remote(),        /* forward declaration */
  1110. X     *strcat(), *strcpy();
  1111. X
  1112. Xint
  1113. Xuucp_hops(to)
  1114. Xchar *to;
  1115. X{    
  1116. X    /** Given the entire "To:" list, return the number of hops in the
  1117. X        first address (a hop = a '!') or ZERO iff the address is to a
  1118. X          non uucp address.
  1119. X    **/
  1120. X
  1121. X    register int hopcount = 0, index;
  1122. X
  1123. X    for (index = 0; ! whitespace(to[index]) && to[index] != '\0'; index++) {
  1124. X      if (to[index] == '!')
  1125. X        hopcount++;
  1126. X      else if (to[index] == '@' || to[index] == '%' || to[index] == ':')
  1127. X        return(0);    /* don't continue! */
  1128. X    }
  1129. X
  1130. X    return(hopcount);
  1131. X}
  1132. X    
  1133. Xchar *bounce_off_remote(to)
  1134. Xchar *to;
  1135. X{
  1136. X    /** Return an address suitable for framing (no, that's not it...)
  1137. X        Er, suitable for including in a 'cc' line so that it ends up
  1138. X        with the bounceback address.  The method is to take the first 
  1139. X        address in the To: entry and break it into machines, then 
  1140. X        build a message up from that.  For example, consider the
  1141. X        following address:
  1142. X            a!b!c!d!e!joe
  1143. X        the bounceback address would be;
  1144. X            a!b!c!d!e!d!c!b!a!ourmachine!ourname
  1145. X        simple, eh?
  1146. X    **/
  1147. X
  1148. X    static char address[LONG_STRING];    /* BEEG address buffer! */
  1149. X
  1150. X    char   host[MAX_HOPS][SHORT_SLEN];    /* for breaking up addr */
  1151. X    register int hostcount = 0, hindex = 0, 
  1152. X           index;
  1153. X
  1154. X    for (index = 0; !whitespace(to[index]) && to[index] != '\0'; index++) {
  1155. X      if (to[index] == '!') {
  1156. X        host[hostcount][hindex] = '\0';
  1157. X        hostcount++;
  1158. X        hindex = 0;
  1159. X      }
  1160. X      else 
  1161. X        host[hostcount][hindex++] = to[index];
  1162. X    }
  1163. X
  1164. X    /* we have hostcount hosts... */
  1165. X
  1166. X    strcpy(address, host[0]);    /* initialize it! */
  1167. X
  1168. X    for (index=1; index < hostcount; index++) {
  1169. X      strcat(address, "!");
  1170. X      strcat(address, host[index]);
  1171. X    }
  1172. X    
  1173. X    /* and now the same thing backwards... */
  1174. X
  1175. X    for (index = hostcount -2; index > -1; index--) {
  1176. X      strcat(address, "!");
  1177. X      strcat(address, host[index]);
  1178. X    }
  1179. X
  1180. X    /* and finally, let's tack on our machine and login name */
  1181. X
  1182. X    strcat(address, "!");
  1183. X    strcat(address, hostname);
  1184. X    strcat(address, "!");
  1185. X    strcat(address, username);
  1186. X
  1187. X    /* and we're done!! */
  1188. X
  1189. X    return( (char *) address );
  1190. X}
  1191. END_OF_src/bounceback.c
  1192. if test 2525 -ne `wc -c <src/bounceback.c`; then
  1193.     echo shar: \"src/bounceback.c\" unpacked with wrong size!?
  1194. fi
  1195. # end of overwriting check
  1196. fi
  1197. echo shar: Extracting \"src/connect_to.c\" \(3860 characters\)
  1198. if test -f src/connect_to.c ; then 
  1199.   echo shar: Will not over-write existing file \"src/connect_to.c\"
  1200. else
  1201. sed "s/^X//" >src/connect_to.c <<'END_OF_src/connect_to.c'
  1202. X/**            connect_to.c            **/
  1203. X
  1204. X/** This contains the routine(s) needed to have the Elm mailer figure
  1205. X    out what machines the current machine can talk to.   This can be
  1206. X    done in one of two ways - either the program can read the L.sys
  1207. X    file, or (if it fails or "UUNAME" define is present) will invoke
  1208. X    uuname to a file, then read the file in!
  1209. X
  1210. X    (C) Copyright Dave Taylor, 1986
  1211. X**/
  1212. X
  1213. X#include "headers.h"
  1214. X
  1215. Xchar *strcpy();
  1216. X
  1217. Xstruct lsys_rec *pmalloc(); 
  1218. X
  1219. Xget_connections()
  1220. X{
  1221. X
  1222. X    /** get the direct connections that this machine has, by hook
  1223. X        or by crook (so to speak) 
  1224. X    **/
  1225. X
  1226. X#ifndef USE_UUNAME
  1227. X    FILE *lsysfile;
  1228. X    char  buffer[SLEN], sysname[NLEN];
  1229. X    struct lsys_rec *system_record, *previous_record;
  1230. X    int    loc_on_line;
  1231. X
  1232. X    previous_record = NULL;
  1233. X    if ((lsysfile = fopen(Lsys,"r")) == NULL) {
  1234. X      dprint1(1, "Warning: Can't open L.sys file %s (read_lsys)\n", Lsys);
  1235. X#endif
  1236. X
  1237. X      if (read_uuname() == -1) {
  1238. X        error("Warning: couldn't figure out system connections...");
  1239. X        talk_to_sys = NULL;
  1240. X      }
  1241. X
  1242. X#ifndef USE_UUNAME
  1243. X      /** ELSE: already read in uuname() output if we're here!! **/
  1244. X      return;
  1245. X    }
  1246. X
  1247. X    while (fgets(buffer, SLEN, lsysfile) != NULL) {
  1248. X      sscanf(buffer,"%s", sysname);
  1249. X
  1250. X      if (previous_record == NULL) {
  1251. X        dprint1(2, "L.sys\tdirect connection to %s, ", sysname);
  1252. X        loc_on_line = 30 + strlen(sysname);  
  1253. X        previous_record = pmalloc(sizeof *talk_to_sys);
  1254. X
  1255. X        strcpy(previous_record->name, sysname);
  1256. X        previous_record->next = NULL;
  1257. X        talk_to_sys = previous_record;
  1258. X      }
  1259. X      else if (! talk_to(sysname) && sysname[0] != '#') {
  1260. X        if (loc_on_line + strlen(sysname) > 80) {
  1261. X          dprint0(2, "\n\t");
  1262. X          loc_on_line = 8;
  1263. X        }
  1264. X        dprint1(2, "%s, ", sysname);
  1265. X        loc_on_line += (strlen(sysname) + 2);
  1266. X        system_record = pmalloc(sizeof *talk_to_sys);
  1267. X      
  1268. X        strcpy(system_record->name, sysname);
  1269. X        system_record->next = NULL;
  1270. X        previous_record->next = system_record;
  1271. X        previous_record = system_record;
  1272. X      }
  1273. X    }
  1274. X
  1275. X    fclose(lsysfile);
  1276. X
  1277. X    if (loc_on_line != 8)
  1278. X      dprint0(2, "\n");
  1279. X
  1280. X    dprint0(2, "\n");            /* for a nice format! Yeah! */
  1281. X#endif
  1282. X}
  1283. X
  1284. Xint
  1285. Xread_uuname()
  1286. X{
  1287. X    /** This routine trys to use the uuname routine to get the names of
  1288. X        all the machines that this machine connects to...it returns
  1289. X        -1 on failure.
  1290. X    **/
  1291. X
  1292. X    FILE *fd;
  1293. X    char  buffer[SLEN], filename[SLEN];
  1294. X    struct lsys_rec *system_record, *previous_record;
  1295. X    int   loc_on_line;
  1296. X
  1297. X    sprintf(filename, "%s%d", temp_uuname, getpid());
  1298. X    sprintf(buffer,"%s > %s", uuname, filename);
  1299. X
  1300. X    if (system_call(buffer, SH) != 0) {
  1301. X      dprint0(1, "Can't get uuname info - system call failed!\n");
  1302. X      unlink(filename);    /* insurance */
  1303. X      return(-1);
  1304. X    }
  1305. X    
  1306. X    if ((fd = fopen(filename, "r")) == NULL) {
  1307. X      dprint1(1, "Can't get uuname info - can't open file %s for reading\n",
  1308. X           filename);
  1309. X      unlink(filename);    /* insurance */
  1310. X      return(-1);
  1311. X    }
  1312. X    
  1313. X    previous_record = NULL;
  1314. X
  1315. X    while (fgets(buffer, SLEN, fd) != NULL) {
  1316. X      no_ret(buffer);
  1317. X      if (previous_record == NULL) {
  1318. X        dprint1(2, "uuname\tdirect connection to %s, ", buffer);
  1319. X        loc_on_line = 30 + strlen(buffer);
  1320. X        previous_record = pmalloc(sizeof *talk_to_sys);
  1321. X
  1322. X        strcpy(previous_record->name, buffer);
  1323. X        previous_record->next = NULL;
  1324. X        talk_to_sys = previous_record;
  1325. X      }
  1326. X      else {    /* don't have to check uniqueness - uuname does that! */
  1327. X        if (loc_on_line + strlen(buffer) > 80) {
  1328. X          dprint0(2, "\n\t");
  1329. X          loc_on_line = 8;
  1330. X        }
  1331. X        dprint1(2, "%s, ", buffer);
  1332. X        loc_on_line += (strlen(buffer) + 2);
  1333. X        system_record = pmalloc(sizeof *talk_to_sys);
  1334. X      
  1335. X        strcpy(system_record->name, buffer);
  1336. X        system_record->next = NULL;
  1337. X        previous_record->next = system_record;
  1338. X        previous_record = system_record;
  1339. X      }
  1340. X    }
  1341. X
  1342. X    fclose(fd);
  1343. X
  1344. X    (void) unlink(filename);        /* kill da temp file!! */
  1345. X
  1346. X    dprint0(2, "\n");            /* for a nice format! Yeah! */
  1347. X
  1348. X    return(0);                /* it all went okay... */
  1349. X}
  1350. END_OF_src/connect_to.c
  1351. if test 3860 -ne `wc -c <src/connect_to.c`; then
  1352.     echo shar: \"src/connect_to.c\" unpacked with wrong size!?
  1353. fi
  1354. # end of overwriting check
  1355. fi
  1356. echo shar: Extracting \"src/errno.c\" \(2500 characters\)
  1357. if test -f src/errno.c ; then 
  1358.   echo shar: Will not over-write existing file \"src/errno.c\"
  1359. else
  1360. sed "s/^X//" >src/errno.c <<'END_OF_src/errno.c'
  1361. X/**        errno.c            **/
  1362. X
  1363. X/** This routine maps error numbers to error names and error messages.
  1364. X    These are all directly ripped out of the include file errno.h, and
  1365. X    are HOPEFULLY standardized across the different breeds of Unix!!
  1366. X
  1367. X    If (alas) yours are different, you should be able to use awk to
  1368. X    mangle your errno.h file quite simply...
  1369. X
  1370. X   (C) Copyright 1986 Dave Taylor
  1371. X**/
  1372. X
  1373. X#include "headers.h"
  1374. X
  1375. Xchar *err_name[] = { 
  1376. X/* 0 */            "NOERROR", "No error status currently",
  1377. X/* 1 */        "EPERM",   "Not super-user",
  1378. X/* 2 */        "ENOENT",  "No such file or directory",
  1379. X/* 3 */        "ESRCH",   "No such process",
  1380. X/* 4 */        "EINTR",   "Interrupted system call",
  1381. X/* 5 */        "EIO",     "I/O error",
  1382. X/* 6 */        "ENXIO",   "No such device or address",
  1383. X/* 7 */        "E2BIG",   "Arg list too long",
  1384. X/* 8 */        "ENOEXEC", "Exec format error",
  1385. X/* 9 */        "EBADF",   "Bad file number",
  1386. X/* 10 */    "ECHILD",  "No children",
  1387. X/* 11 */    "EAGAIN",  "No more processes",
  1388. X/* 12 */    "ENOMEM",  "Not enough core",
  1389. X/* 13 */    "EACCES",  "Permission denied",
  1390. X/* 14 */    "EFAULT",  "Bad address",
  1391. X/* 15 */    "ENOTBLK", "Block device required",
  1392. X/* 16 */    "EBUSY",   "Mount device busy",
  1393. X/* 17 */    "EEXIST",  "File exists",
  1394. X/* 18 */    "EXDEV",   "Cross-device link",
  1395. X/* 19 */    "ENODEV",  "No such device",
  1396. X/* 20 */    "ENOTDIR", "Not a directory",
  1397. X/* 21 */    "EISDIR",  "Is a directory",
  1398. X/* 22 */    "EINVAL",  "Invalid argument",
  1399. X/* 23 */    "ENFILE",  "File table overflow",
  1400. X/* 24 */    "EMFILE",  "Too many open files",
  1401. X/* 25 */    "ENOTTY",  "Not a typewriter",
  1402. X/* 26 */    "ETXTBSY", "Text file busy",
  1403. X/* 27 */    "EFBIG",   "File too large",
  1404. X/* 28 */    "ENOSPC",  "No space left on device",
  1405. X/* 29 */    "ESPIPE",  "Illegal seek",
  1406. X/* 30 */    "EROFS",   "Read only file system",
  1407. X/* 31 */    "EMLINK",  "Too many links",
  1408. X/* 32 */    "EPIPE",   "Broken pipe",
  1409. X/* 33 */    "EDOM",    "Math arg out of domain of func",
  1410. X/* 34 */    "ERANGE",  "Math result not representable",
  1411. X/* 35 */    "ENOMSG",  "No message of desired type",
  1412. X/* 36 */    "EIDRM",   "Identifier removed"
  1413. X    };
  1414. X
  1415. Xchar *strcpy();
  1416. X
  1417. Xchar *error_name(errnumber)
  1418. Xint errnumber;
  1419. X{
  1420. X    static char buffer[50];
  1421. X
  1422. X    if (errnumber < 0 || errnumber > 36) 
  1423. X      sprintf(buffer,"ERR-UNKNOWN (%d)", errnumber);
  1424. X    else
  1425. X      strcpy(buffer, err_name[2*errnumber]);
  1426. X
  1427. X    return( (char *) buffer);
  1428. X}
  1429. X
  1430. Xchar *error_description(errnumber)
  1431. Xint errnumber;
  1432. X{
  1433. X    static char buffer[50];
  1434. X
  1435. X    if (errnumber < 0 || errnumber > 36) 
  1436. X      sprintf(buffer,"Unknown error - %d - No description", errnumber);
  1437. X    else
  1438. X      strcpy(buffer, err_name[2*errnumber + 1]);
  1439. X
  1440. X    return ( (char *) buffer);
  1441. X}
  1442. END_OF_src/errno.c
  1443. if test 2500 -ne `wc -c <src/errno.c`; then
  1444.     echo shar: \"src/errno.c\" unpacked with wrong size!?
  1445. fi
  1446. # end of overwriting check
  1447. fi
  1448. echo shar: Extracting \"src/fileio.c\" \(3020 characters\)
  1449. if test -f src/fileio.c ; then 
  1450.   echo shar: Will not over-write existing file \"src/fileio.c\"
  1451. else
  1452. sed "s/^X//" >src/fileio.c <<'END_OF_src/fileio.c'
  1453. X/**            fileio.c            **/
  1454. X
  1455. X/** File I/O routines, including deletion from the mailbox! 
  1456. X
  1457. X    (C) Copyright 1986 Dave Taylor
  1458. X**/
  1459. X
  1460. X#include "headers.h"
  1461. X#include <ctype.h>
  1462. X#include <errno.h>
  1463. X
  1464. X#ifdef BSD
  1465. X#undef tolower
  1466. X#endif
  1467. X
  1468. Xextern int errno;
  1469. X
  1470. Xchar *error_name();
  1471. X
  1472. Xcopy_message(prefix, dest_file, remove_header, remote)
  1473. Xchar *prefix;
  1474. XFILE *dest_file;
  1475. Xint  remove_header, remote;
  1476. X{
  1477. X    /** Copy current message to destination file, with optional 'prefix' 
  1478. X        as the prefix for each line.  If remove_header is true, it will 
  1479. X        skip lines in the message until it finds the end of header line...
  1480. X            then it will start copying into the file... If remote is true
  1481. X        then it will append "remote from <hostname>" at the end of the
  1482. X        very first line of the file (for remailing) 
  1483. X    **/
  1484. X
  1485. X    char buffer[LONG_SLEN];
  1486. X    register int ok = 1, lines, in_header = 1, first_line = TRUE;
  1487. X
  1488. X    /** get to the first line of the message desired **/
  1489. X
  1490. X    if (fseek(mailfile, header_table[current-1].offset, 0) == -1) {
  1491. X       dprint2(1,"ERROR: Attempt to seek %d bytes into file failed (%s)",
  1492. X        header_table[current-1].offset, "copy_message");
  1493. X       error1("ELM [seek] failed trying to read %d bytes into file",
  1494. X         header_table[current-1].offset);
  1495. X       return;
  1496. X    }
  1497. X
  1498. X    /* how many lines in message? */
  1499. X
  1500. X    lines = header_table[current-1].lines;
  1501. X
  1502. X    /* now while not EOF & still in message... copy it! */
  1503. X
  1504. X    while (ok && lines--) {
  1505. X      ok = (int) (fgets(buffer, LONG_SLEN, mailfile) != NULL);
  1506. X      if (strlen(buffer) < 2) in_header = 0;
  1507. X      if (ok) 
  1508. X    if (! (remove_header && in_header))
  1509. X      if (first_line && remote) {
  1510. X        no_ret(buffer);
  1511. X        fprintf(dest_file, "%s%s remote from %s\n",
  1512. X            prefix, buffer, hostname);
  1513. X        first_line = FALSE;
  1514. X      }
  1515. X      else if (! in_header && first_word(buffer, "From ")) {
  1516. X        dprint0(1,"\n*** Internal Problem...Tried to add the following;\n");
  1517. X        dprint1(1,"  '%s'\nto output file (copy_message) ***\n", buffer);
  1518. X        ok = 0;    /* STOP NOW! */
  1519. X      }
  1520. X      else
  1521. X        fprintf(dest_file, "%s%s", prefix, buffer);
  1522. X    }
  1523. X    if (strlen(buffer) + strlen(prefix) > 1)
  1524. X      fprintf(dest_file, "\n");    /* blank line to keep mailx happy *sigh* */
  1525. X}
  1526. X
  1527. X#ifdef SITE_HIDING
  1528. X
  1529. Xint
  1530. Xis_a_hidden_user(specific_username)
  1531. Xchar *specific_username;
  1532. X{
  1533. X    /** Returns true iff the username is present in the list of
  1534. X       'hidden users' on the system.
  1535. X    **/
  1536. X    
  1537. X    FILE *hidden_users;
  1538. X    char  buffer[SLEN];
  1539. X
  1540. X    this is shit and should be flagged as bad news!
  1541. X
  1542. X    if ((hidden_users = fopen (HIDDEN_SITE_USERS,"r")) == NULL) {
  1543. X      dprint2(1,"Couldn't open hidden site file %s [%s]\n",
  1544. X          HIDDEN_SITE_USERS, error_name(errno));
  1545. X      return(FALSE);
  1546. X    }
  1547. X
  1548. X    while (fscanf(hidden_users, "%s", buffer) != EOF)
  1549. X      if (strcmp(buffer, specific_username) == 0) {
  1550. X        dprint1(3,"** Found user '%s' in hidden site file!\n",
  1551. X            specific_username);
  1552. X        fclose(hidden_users);
  1553. X        return(TRUE);
  1554. X      }
  1555. X
  1556. X    fclose(hidden_users);
  1557. X    dprint1(3,"** Couldn't find user '%s' in hidden site file!\n",
  1558. X        specific_username);
  1559. X
  1560. X    return(FALSE);
  1561. X}
  1562. X
  1563. X#endif
  1564. END_OF_src/fileio.c
  1565. if test 3020 -ne `wc -c <src/fileio.c`; then
  1566.     echo shar: \"src/fileio.c\" unpacked with wrong size!?
  1567. fi
  1568. # end of overwriting check
  1569. fi
  1570. echo shar: Extracting \"src/mkhdrs.c\" \(3189 characters\)
  1571. if test -f src/mkhdrs.c ; then 
  1572.   echo shar: Will not over-write existing file \"src/mkhdrs.c\"
  1573. else
  1574. sed "s/^X//" >src/mkhdrs.c <<'END_OF_src/mkhdrs.c'
  1575. X/**            mkhdrs.c        **/
  1576. X
  1577. X/** This contains all the header generating routines for the ELM
  1578. X    program.
  1579. X
  1580. X    (C) Copyright 1985 Dave Taylor
  1581. X
  1582. X**/
  1583. X
  1584. X#include <stdio.h>
  1585. X#include "headers.h"
  1586. X
  1587. Xextern char in_reply_to[SLEN];
  1588. X
  1589. Xchar *strcpy();
  1590. Xunsigned long sleep();
  1591. X
  1592. Xgenerate_reply_to(msg)
  1593. Xint msg;
  1594. X{
  1595. X    /** Generate an 'in-reply-to' message... **/
  1596. X    char buffer[SLEN];
  1597. X
  1598. X
  1599. X    if (msg == -1)        /* not a reply! */
  1600. X      in_reply_to[0] = '\0';
  1601. X    else {
  1602. X      if (chloc(header_table[msg].from, '!') != -1)
  1603. X        tail_of(header_table[msg].from, buffer, FALSE);
  1604. X      else
  1605. X        strcpy(buffer, header_table[msg].from);
  1606. X      sprintf(in_reply_to, "Message from \"%s\" of %s %s, %s at %s",
  1607. X          buffer,
  1608. X          header_table[msg].month,
  1609. X          header_table[msg].day,
  1610. X          header_table[msg].year,
  1611. X          header_table[msg].time);
  1612. X    }
  1613. X}
  1614. X
  1615. Xadd_mailheaders(filedesc)
  1616. XFILE *filedesc;
  1617. X{
  1618. X    /** Add the users .mailheaders file if available.  Allow backquoting 
  1619. X        in the file, too, for fortunes, etc...*shudder*
  1620. X    **/
  1621. X
  1622. X    FILE *fd;
  1623. X    char filename[SLEN], buffer[LONG_SLEN];
  1624. X
  1625. X    sprintf(filename, "%s/%s", home, mailheaders);
  1626. X
  1627. X    if ((fd = fopen(filename, "r")) != NULL) {
  1628. X      while (fgets(buffer, LONG_SLEN, fd) != NULL)
  1629. X        if (strlen(buffer) < 2) {
  1630. X          dprint0(2,
  1631. X             "Strlen of line from .elmheaders is < 2 (write_header_info)");
  1632. X          if (mail_only)
  1633. X            printf("Warning: blank line in %s ignored!\r\n", filename);
  1634. X          else {
  1635. X            error1("Warning: blank line in %s ignored!", filename);
  1636. X            sleep(2);
  1637. X          }
  1638. X        }
  1639. X        else if (occurances_of(BACKQUOTE, buffer) == 2) 
  1640. X          expand_backquote(buffer, filedesc);
  1641. X        else 
  1642. X          fprintf(filedesc, "%s", buffer);
  1643. X
  1644. X        fclose(fd);
  1645. X    }
  1646. X}
  1647. X
  1648. Xexpand_backquote(buffer, filedesc)
  1649. Xchar *buffer;
  1650. XFILE *filedesc;
  1651. X{
  1652. X    /** This routine is called with a line of the form:
  1653. X        Fieldname: `command`
  1654. X        and is expanded accordingly..
  1655. X    **/
  1656. X
  1657. X    FILE *fd;
  1658. X    char command[SLEN], command_buffer[SLEN], fname[SLEN],
  1659. X         prefix[SLEN];
  1660. X    register int i, j = 0;
  1661. X
  1662. X    for (i=0; buffer[i] != BACKQUOTE; i++)
  1663. X      prefix[j++] = buffer[i];
  1664. X    prefix[j] = '\0';
  1665. X
  1666. X    j = 0;
  1667. X
  1668. X    for (i=chloc(buffer, BACKQUOTE)+1; buffer[i] != BACKQUOTE;i++)
  1669. X      command[j++] = buffer[i];
  1670. X    command[j] = '\0';
  1671. X
  1672. X    sprintf(fname,"%s%d", temp_print, getpid());
  1673. X
  1674. X    sprintf(command_buffer, "%s > %s", command, fname);
  1675. X
  1676. X    system_call(command_buffer, SH);
  1677. X
  1678. X    if ((fd = fopen(fname, "r")) == NULL) {
  1679. X      if (mail_only)
  1680. X        printf("\nbackquoted command \"%s\" in .elmheaders failed\n", 
  1681. X           command);
  1682. X      else
  1683. X        error1("backquoted command \"%s\" in .elmheaders failed", command);
  1684. X      return;    
  1685. X    }
  1686. X
  1687. X    /* If we get a line that is less than 80 - length of prefix then we
  1688. X       can toss it on the same line, otherwise, simply prepend each line
  1689. X       *starting with this line* with a leading tab and cruise along */
  1690. X
  1691. X    if (fgets(command_buffer, SLEN, fd) == NULL) 
  1692. X      fprintf(filedesc, prefix);
  1693. X    else {
  1694. X      if (strlen(command_buffer) + strlen(prefix) < 80) 
  1695. X        fprintf(filedesc, "%s%s", prefix, command_buffer);
  1696. X      else
  1697. X        fprintf(filedesc, "%s\n\t%s", prefix, command_buffer);
  1698. X      
  1699. X      while (fgets(command_buffer, SLEN, fd) != NULL) 
  1700. X        fprintf(filedesc, "\t%s", command_buffer);
  1701. X    
  1702. X      fclose(fd);
  1703. X    }
  1704. X
  1705. X    unlink(fname);    /* don't leave the temp file laying around! */
  1706. X}
  1707. END_OF_src/mkhdrs.c
  1708. if test 3189 -ne `wc -c <src/mkhdrs.c`; then
  1709.     echo shar: \"src/mkhdrs.c\" unpacked with wrong size!?
  1710. fi
  1711. # end of overwriting check
  1712. fi
  1713. echo shar: Extracting \"src/showmsg_cmd.c\" \(3188 characters\)
  1714. if test -f src/showmsg_cmd.c ; then 
  1715.   echo shar: Will not over-write existing file \"src/showmsg_cmd.c\"
  1716. else
  1717. sed "s/^X//" >src/showmsg_cmd.c <<'END_OF_src/showmsg_cmd.c'
  1718. X/**            showmsg_cmd.c            **/
  1719. X
  1720. X/** This is an interface for the showmsg command line.  The possible
  1721. X    functions that could be invoked from the showmsg command line are
  1722. X    almost as numerous as those from the main command line and include
  1723. X    the following;
  1724. X
  1725. X       |    = pipe this message to command...
  1726. X       !    = call Unix command
  1727. X       <    = scan message for calendar info
  1728. X       b    = bounce (remail) message
  1729. X       d    = mark message for deletion
  1730. X       e    = edit entire mailbox
  1731. X       f    = forward message
  1732. X       g    = group reply
  1733. X       j,n  = move to body of next message
  1734. X       k    = move to body of previous message
  1735. X       p    = print this (all tagged) message
  1736. X       r    = reply to this message
  1737. X       s    = save this message to a maibox/folder 
  1738. X       t    = tag this message
  1739. X       x    = Exit Elm NOW
  1740. X
  1741. X    all commands not explicitly listed here are returned as unprocessed
  1742. X    to be dealt with at the main command level.
  1743. X
  1744. X    This function returns 0 if it dealt with the command, or the command
  1745. X    otherwise.
  1746. X**/
  1747. X
  1748. X#include "headers.h"
  1749. X
  1750. Xprocess_showmsg_command(command)
  1751. Xchar command;
  1752. X{
  1753. X    switch (command) {
  1754. X      case '|' : clear_bottom_of_screen();
  1755. X             PutLine0(LINES-3,0,"Command: pipe");
  1756. X             softkeys_off();
  1757. X             (void) pipe();    /* do pipe regardless */
  1758. X             softkeys_on();
  1759. X             return(0);        /* must have new screen */
  1760. X
  1761. X      case '!' : clear_bottom_of_screen();
  1762. X             PutLine0(LINES-3,0,"Command: system call");
  1763. X             softkeys_off();
  1764. X             (void) subshell();    /* do shell regardless */
  1765. X             softkeys_on();
  1766. X             return(0);        /* must have new screen */
  1767. X
  1768. X      case '<' : 
  1769. X#ifdef ENABLE_CALENDAR
  1770. X             scan_calendar();
  1771. X#else
  1772. X             error("can't scan for calendar entries!");
  1773. X#endif
  1774. X            break;
  1775. X
  1776. X      case 'b' : clear_bottom_of_screen();
  1777. X             PutLine0(LINES-3,0,"Command: bounce message");
  1778. X             remail();
  1779. X             return(0);        /* must have new screen */
  1780. X
  1781. X      case 'd' : delete(TRUE);
  1782. X             break;
  1783. X
  1784. X      case 'e' : edit_mailbox();
  1785. X             return(0);        /* must have new screen */
  1786. X
  1787. X      case 'f' : clear_bottom_of_screen();
  1788. X             PutLine0(LINES-3,0,"Command: forward message");
  1789. X             (void) forward();
  1790. X             return(0);        /* must have new screen */
  1791. X
  1792. X      case 'g' : clear_bottom_of_screen();
  1793. X             PutLine0(LINES-3,0,"Command: group reply");
  1794. X             (void) reply_to_everyone();
  1795. X             return(0);        /* must have new screen */
  1796. X
  1797. X      case 'j' :
  1798. X      case 'n' : if (current < message_count)
  1799. X               show_msg(++current);
  1800. X             return(0);    
  1801. X
  1802. X      case 'k' : if (current > 0)
  1803. X               show_msg(--current);
  1804. X             return(0);
  1805. X
  1806. X
  1807. X      case 'p' : printmsg();    
  1808. X             break;
  1809. X
  1810. X      case 'r' : clear_bottom_of_screen();
  1811. X             PutLine0(LINES-3,0,"Command: reply to message");
  1812. X             (void) reply();
  1813. X             return(0);        /* must have new screen */
  1814. X
  1815. X      case 's' : clear_bottom_of_screen();
  1816. X             PutLine0(LINES-3,0,"Command: save message");
  1817. X             (void) save();
  1818. X             break;
  1819. X
  1820. X      case 't' : tag_message();    
  1821. X             break;
  1822. X
  1823. X      case 'x' : leave();
  1824. X
  1825. X      case '\n':
  1826. X      case '\r': return(0);        /* avoid <return> looping */
  1827. X
  1828. X      default  : return(command);    /* couldn't deal with it! */
  1829. X    }
  1830. X
  1831. X    return(1);    /* done with it! */
  1832. X}
  1833. X
  1834. Xclear_bottom_of_screen()
  1835. X{
  1836. X    /** clear the last 4 lines of the screen... **/
  1837. X
  1838. X    MoveCursor(LINES-4, 0);
  1839. X    CleartoEOS();
  1840. X}
  1841. END_OF_src/showmsg_cmd.c
  1842. if test 3188 -ne `wc -c <src/showmsg_cmd.c`; then
  1843.     echo shar: \"src/showmsg_cmd.c\" unpacked with wrong size!?
  1844. fi
  1845. # end of overwriting check
  1846. fi
  1847. echo shar: Extracting \"src/softkeys.c\" \(2576 characters\)
  1848. if test -f src/softkeys.c ; then 
  1849.   echo shar: Will not over-write existing file \"src/softkeys.c\"
  1850. else
  1851. sed "s/^X//" >src/softkeys.c <<'END_OF_src/softkeys.c'
  1852. X/**            softkeys.c            **/
  1853. X
  1854. X/** This file and associated routines: (C) Copyright 1986, Dave Taylor **/
  1855. X
  1856. X#include <stdio.h>
  1857. X#include "headers.h"
  1858. X
  1859. Xdefine_softkeys(level)
  1860. Xint level;
  1861. X{
  1862. X    if (! hp_softkeys) return;
  1863. X
  1864. X    if (level == MAIN) {
  1865. X
  1866. X      define_key(f1, "  Show     Msg",   "\r");
  1867. X      define_key(f2, "  Mail     Msg",   "m");
  1868. X      define_key(f3, "  Reply  to Msg",  "r");
  1869. X
  1870. X      if (user_level == 0) {
  1871. X        define_key(f4, "  Save     Msg",   "s");
  1872. X        define_key(f5, " Delete    Msg",   "d");
  1873. X        define_key(f6, "Undelete   Msg",   "u");
  1874. X         }
  1875. X      else {
  1876. X        define_key(f4, " Change  Mailbox", "c");
  1877. X        define_key(f5, "  Save     Msg",   "s");
  1878. X        define_key(f6, " Delete/Undelete", "^");
  1879. X      }
  1880. X
  1881. X      define_key(f7, " Print     Msg",   "p");
  1882. X      define_key(f8, "  Quit     Elm",   "q");
  1883. X    }
  1884. X    else if (level == ALIAS) {
  1885. X      define_key(f1, " Alias  Current",  "a");
  1886. X      define_key(f2, " Check  Person",   "p");
  1887. X      define_key(f3, " Check  System",   "s");
  1888. X      define_key(f4, " Make    Alias",   "m");
  1889. X      clear_key(f5);
  1890. X      clear_key(f6);
  1891. X      clear_key(f7);
  1892. X      define_key(f8, " Return  to Elm",  "r");
  1893. X    }
  1894. X    else if (level == YESNO) {
  1895. X      define_key(f1, "  Yes",  "y");
  1896. X      clear_key(f2);
  1897. X      clear_key(f3);
  1898. X      clear_key(f4);
  1899. X      clear_key(f5);
  1900. X      clear_key(f6);
  1901. X      clear_key(f7);
  1902. X      define_key(f8, "   No",  "n");
  1903. X    }
  1904. X    else if (level == READ) {
  1905. X      define_key(f1, "  Next    Page  ", " ");
  1906. X      clear_key(f2);
  1907. X      define_key(f3, "  Skip    Page  ", "f");
  1908. X      clear_key(f4);
  1909. X      clear_key(f5);
  1910. X      clear_key(f6);
  1911. X      clear_key(f7);
  1912. X      define_key(f8, " Return  to Elm", "q");
  1913. X    }
  1914. X    else if (level == CHANGE) {
  1915. X      define_key(f1, "  Mail  Directry", "=/");
  1916. X      define_key(f2, "  Home  Directry", "~/");
  1917. X      clear_key(f3);
  1918. X      define_key(f4, "Incoming Mailbox", "!\n");
  1919. X      clear_key(f5);
  1920. X      clear_key(f6);
  1921. X      clear_key(f7);
  1922. X      define_key(f8, " Cancel", "\n");
  1923. X    }
  1924. X
  1925. X    softkeys_on();
  1926. X}
  1927. X
  1928. Xdefine_key(key, display, send)
  1929. Xint key;
  1930. Xchar *display, *send;
  1931. X{
  1932. X
  1933. X    char buffer[30];
  1934. X
  1935. X    sprintf(buffer,"%s%s", display, send);
  1936. X
  1937. X    fprintf(stderr, "%c&f%dk%dd%dL%s", ESCAPE, key,
  1938. X        strlen(display), strlen(send), buffer);
  1939. X    fflush(stdout);
  1940. X}
  1941. X
  1942. Xsoftkeys_on()    
  1943. X{ 
  1944. X    /* enable (esc&s1A) turn on softkeys (esc&jB) and turn on MENU 
  1945. X       and USER/SYSTEM options. */
  1946. X
  1947. X    if (hp_softkeys) {
  1948. X      fprintf(stderr, "%c&s1A%c&jB%c&jR", ESCAPE, ESCAPE, ESCAPE); 
  1949. X      fflush(stdout);
  1950. X    }
  1951. X    
  1952. X}
  1953. X
  1954. Xsoftkeys_off()    
  1955. X{ 
  1956. X    /* turn off softkeys (esc&j@) */
  1957. X
  1958. X    if (hp_softkeys) {
  1959. X      fprintf(stderr, "%c&s0A%c&j@", ESCAPE, ESCAPE); 
  1960. X      fflush(stdout);
  1961. X    }
  1962. X}
  1963. X
  1964. Xclear_key(key)  
  1965. X{     
  1966. X    /** set a key to nothing... **/
  1967. X
  1968. X    if (hp_softkeys) 
  1969. X       define_key(key, "                ", ""); 
  1970. X}
  1971. END_OF_src/softkeys.c
  1972. if test 2576 -ne `wc -c <src/softkeys.c`; then
  1973.     echo shar: \"src/softkeys.c\" unpacked with wrong size!?
  1974. fi
  1975. # end of overwriting check
  1976. fi
  1977. echo shar: Extracting \"utils/printmail.c\" \(2471 characters\)
  1978. if test -f utils/printmail.c ; then 
  1979.   echo shar: Will not over-write existing file \"utils/printmail.c\"
  1980. else
  1981. sed "s/^X//" >utils/printmail.c <<'END_OF_utils/printmail.c'
  1982. X/**        printmail.c        **/
  1983. X
  1984. X/** print mail, adding a formfeed between each message  **/
  1985. X/** Modified to use stdin if being fed from a pipe.    **/
  1986. X
  1987. X/** (C) Copyright 1985, Dave Taylor **/
  1988. X
  1989. X#include <stdio.h>
  1990. X#include "defs.h"
  1991. X
  1992. Xstatic char ident[] = { WHAT_STRING };
  1993. X
  1994. X#define  dashes          \
  1995. X"\n\n------------------------------------------------------------------------------\n\n"
  1996. X#define  FF            "\014"    /* form feed! */
  1997. X
  1998. XFILE *mailfile;
  1999. Xchar  separator[80];
  2000. X
  2001. Xmain(argc, argv)
  2002. Xint argc;
  2003. Xchar *argv[];
  2004. X{
  2005. X    char infile[80], username[40], c;
  2006. X
  2007. X    strcpy(separator, FF);
  2008. X
  2009. X    argv++;                /* get past argv[0] */
  2010. X
  2011. X    if (argc > 1) 
  2012. X      if (strcmp(*argv, "-d") == 0) {
  2013. X        strcpy(separator, dashes);
  2014. X        --argc;
  2015. X        argv++;
  2016. X      }
  2017. X    
  2018. X    if (argc > 1 && *argv[0] == '-') 
  2019. X        exit(fprintf(stderr, "Usage: printmail {-d} {filename (s)}\n"));
  2020. X    
  2021. X    if (argc == 1) {
  2022. X      strcpy(username, getlogin());
  2023. X      if (strlen(username) == 0)
  2024. X        cuserid(username);
  2025. X      if (isatty(fileno(stdin))) {    /* normal invokation... */
  2026. X        sprintf(infile,"%s/%s",mailhome, username);
  2027. X        if ((mailfile = fopen(infile,"r")) == NULL) {
  2028. X          fprintf(stderr, "No mail!\n");
  2029. X          exit(0);
  2030. X        }
  2031. X      }
  2032. X      else 
  2033. X        mailfile = stdin;    /* read from stdin! */
  2034. X
  2035. X      if (read_headers() == 0)
  2036. X        fprintf(stderr, "No messages in mailbox!\n");
  2037. X    }
  2038. X
  2039. X    if (argc > 1)        /* more than one file - delimit each */
  2040. X      if (strcmp(separator, FF) != 0) 
  2041. X        printf("\t\t\t%s\n%s", *argv, separator);
  2042. X      else
  2043. X        printf("\t\t\t%s\n\n", *argv);    /* Don't put a formfeed! */
  2044. X
  2045. X    while (--argc) {
  2046. X      if ((mailfile = fopen(*argv,"r")) == NULL) {
  2047. X        fprintf(stderr, "Could not open file '%s'!", *argv);
  2048. X        break;
  2049. X      }
  2050. X      else
  2051. X        if (read_headers() == 0)
  2052. X          fprintf(stderr, "No messages in mailbox '%s'!\n", *argv);
  2053. X      argv++;
  2054. X      if (argc-1) {
  2055. X        if (strcmp(separator, FF) != 0) 
  2056. X          printf("%s\t\t\t%s%s", separator, *argv, separator);
  2057. X        else
  2058. X          printf("%s\t\t\t%s\n\n", separator, *argv);
  2059. X      }
  2060. X    }
  2061. X}
  2062. X
  2063. Xint
  2064. Xread_headers()
  2065. X{
  2066. X    char buffer[100];
  2067. X    register int count = 0;
  2068. X
  2069. X    while (fgets(buffer, 100, mailfile) != NULL) 
  2070. X      if (first_word(buffer,"From ")) {
  2071. X        if (real_from(buffer)) {
  2072. X          printf("%s%s", count ? separator : "", buffer);
  2073. X          count++;
  2074. X        }
  2075. X      }
  2076. X      else
  2077. X        printf("%s", buffer);
  2078. X
  2079. X    return(count);
  2080. X}
  2081. X
  2082. Xint
  2083. Xreal_from(buffer)
  2084. Xchar *buffer;
  2085. X{
  2086. X    /***** returns true iff 's' has the seven 'from' fields *****/
  2087. X
  2088. X    char junk[80];
  2089. X
  2090. X    junk[0] = '\0';
  2091. X    sscanf(buffer, "%*s %*s %*s %*s %*s %*s %s", junk);
  2092. X    return(junk[0] != '\0');
  2093. X}
  2094. END_OF_utils/printmail.c
  2095. if test 2471 -ne `wc -c <utils/printmail.c`; then
  2096.     echo shar: \"utils/printmail.c\" unpacked with wrong size!?
  2097. fi
  2098. # end of overwriting check
  2099. fi
  2100. echo shar: End of archive 2 \(of 19\).
  2101. cp /dev/null ark2isdone
  2102. DONE=true
  2103. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ; do
  2104.     if test ! -f ark${I}isdone ; then
  2105.     echo shar: You still need to run archive ${I}.
  2106.     DONE=false
  2107.     fi
  2108. done
  2109. if test "$DONE" = "true" ; then
  2110.     echo You have unpacked all 19 archives.
  2111.     echo "See the Instructions file"
  2112.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2113. fi
  2114. ##  End of shell archive.
  2115. exit 0
  2116.